package com.wxd.boot51.mapper;

import com.wxd.boot51.entity.Weibo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author wxd
 * @version 1.0
 */
@Mapper
public interface WeiboMapper {
    @Insert("insert into weibo values(null,#{content},#{url},#{nick},null,#{userId})")
    void insert(Weibo weibo);

    /**
     * 查询所有微博数据,并且降序排序
     * @return 返回得到的微博集合
     */
    @Select("select id,content,url,nick from weibo order by created desc")
    List<Weibo> select();

    @Delete("delete from weibo where id=#{id}")
    void deleteById(int id);
}
